package com.ios.mapper;

import com.ios.model.entity.Reservation;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 预约记录Mapper接口
 */
public interface ReservationMapper {
    /**
     * 根据ID查询预约
     */
    Reservation selectReservationById(Long id);

    /**
     * 查询预约列表
     */
    List<Reservation> selectReservationList(Reservation reservation);

    /**
     * 新增预约
     */
    int insertReservation(Reservation reservation);

    /**
     * 修改预约
     */
    int updateReservation(Reservation reservation);

    /**
     * 删除预约
     */
    int deleteReservationById(Long id);

    /**
     * 批量删除预约
     */
    int deleteReservationByIds(Long[] ids);

    /**
     * 检查时间段冲突
     */
    int checkTimeSlotConflict(
            @Param("seatId") Long seatId,
            @Param("reservationDate") Date reservationDate,
            @Param("timeSlot") Integer timeSlot,
            @Param("excludeId") Long excludeId,
            @Param("userId") Long userId
    );

    /**
     * 更新过期预约状态
     */
    int updateExpiredReservations(
            @Param("fromStatus") Integer fromStatus,
            @Param("toStatus") Integer toStatus
    );

    /**
     * 更新当天预约为待签到状态
     */
    int updateTodayReservationsToPendingCheckIn(
            @Param("fromStatus") Integer fromStatus,
            @Param("toStatus") Integer toStatus
    );

    List<Reservation> selectReservationsByUserId(Long userId);

    /**
     * 根据状态和日期查询预约记录
     * @param status 状态码
     * @param date 预约日期
     * @return 预约记录列表
     */
    List<Reservation> selectByStatusAndDate(@Param("status") Integer status,
                                            @Param("date") Date date);

    /**
     * 根据状态码查询未审核的预约记录
     * @param uncheckedStatus 未审核状态码
     * @return 预约记录列表
     */
    List<Reservation> selectUncheckedReservations(@Param("uncheckedStatus") Integer uncheckedStatus);

}